package com.neusoft.data.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.neusoft.data.domain.SerForecast;
import com.neusoft.data.service.ISerForecastService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 成绩预测Controller
 * 
 * @author slh
 * @date 2024-01-04
 */
@RestController
@RequestMapping("/courseSelect/forecast")
public class SerForecastController extends BaseController
{
    @Autowired
    private ISerForecastService serForecastService;

    /**
     * 查询成绩预测列表
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:forecast:list')")
    @GetMapping("/list")
    public TableDataInfo list(SerForecast serForecast)
    {
        startPage();
        List<SerForecast> list = serForecastService.selectSerForecastList(serForecast);
        return getDataTable(list);
    }

    /**
     * 导出成绩预测列表
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:forecast:export')")
    @Log(title = "成绩预测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SerForecast serForecast)
    {
        List<SerForecast> list = serForecastService.selectSerForecastList(serForecast);
        ExcelUtil<SerForecast> util = new ExcelUtil<SerForecast>(SerForecast.class);
        util.exportExcel(response, list, "成绩预测数据");
    }

    /**
     * 获取成绩预测详细信息
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:forecast:query')")
    @GetMapping(value = "/{forecastId}")
    public AjaxResult getInfo(@PathVariable("forecastId") Long forecastId)
    {
        return success(serForecastService.selectSerForecastByForecastId(forecastId));
    }

    /**
     * 新增成绩预测
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:forecast:add')")
    @Log(title = "成绩预测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SerForecast serForecast)
    {
        return toAjax(serForecastService.insertSerForecast(serForecast));
    }

    /**
     * 修改成绩预测
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:forecast:edit')")
    @Log(title = "成绩预测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SerForecast serForecast)
    {
        return toAjax(serForecastService.updateSerForecast(serForecast));
    }

    /**
     * 删除成绩预测
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:forecast:remove')")
    @Log(title = "成绩预测", businessType = BusinessType.DELETE)
	@DeleteMapping("/{forecastIds}")
    public AjaxResult remove(@PathVariable Long[] forecastIds)
    {
        return toAjax(serForecastService.deleteSerForecastByForecastIds(forecastIds));
    }
}
